<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'index.jsp' starting page</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<script src="js/jquery-1.8.3.min.js" type="text/javascript"></script>
	
 <script type="text/javascript">
   function page_num(frm,num){
	   //获取第几页
	   frm.pageIndex.value=num;
	   //表单提交
	   frm.submit();
	   
	  
   }
 
 </script>
 
  </head>
  
  <body>
   <form action="DeptServlet?id=1" method="post">
   <input type="hidden" value="1" name="pageIndex">
   <input type="submit" value="查询所有">
   </form>
   
   <table>
           <tr>
           <td>部门编号<td/>
           <td>部门名称<td/>
           <td>地址<td/>
           <tr/>
           <c:forEach var="d" items="${list}" varStatus="status">
           <tr <c:if test="${status.count%2==0}">bgcolor="red"</c:if>>
           <td><a href="dept6.jsp" >${d.deptno}</a><td/>
           <td>${d.dname}<td/>
           <td>${d.loc}<td/>
           <tr/>
          </c:forEach>
        
   </table>
   <div>
      <c:if test="${page.pageIndex>1}">
     <a href="javaScript:page_num(document.forms[0],1)">首页</a>
     <a href="javaScript:page_num(document.forms[0],${page.pageIndex-1})">上一页</a>
     </c:if>
     
      <c:if test="${page.pageIndex<page.pageCount}">
     <a href="javaScript:page_num(document.forms[0],${page.pageIndex+1})">下一页</a>
     <a href="javaScript:page_num(document.forms[0],${page.pageCount})">尾页</a>
     </c:if>
     第${page.pageIndex }页
      共${page.pageCount }页
      共${page.counts }条数据
   </div>
     <form action="DeptServlet?id=2" method="post">
     请输入部门编号:<input type="text" name="deptno">
     <input type="submit" value="查询">
     </form>
     <form action="DeptServlet?id=3" method="post">
     请输入要删除的部门编号:<input type="text" name="deptn">
     <input type="submit" value="删除">
     </form>
     <form action="DeptServlet?id=4" method="post">
     请输入要插入的部门编号:<input type="text" name="deptnn"> <br>
          请输入要插入的部门名称:<input type="text" name="deptnnn"><br>	
          请输入要插入的部门地址:<input type="text" name="deptnnnn">
     
     <input type="submit" value="确认插入">
     
  </body>
</html>
